/*
package cn.sunjian.shop_up.activity;

import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.animation.CycleInterpolator;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

import Cheeses;
import cn.sunjian.myslidingmenu.MySlidingMenu;
import cn.shop.dys.R;
import BaseFragment;
import OneFragment;
import ThreeFragment;
import TwoFragment;
import ChangeColorIconWithText;
import MainContenLinearLayout;
import NoScrollViewPager;

public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener, View.OnClickListener, ViewPager.OnPageChangeListener {
    @ViewInject(R.id.view_main)
    private MainContenLinearLayout mViewMain;
    @ViewInject(R.id.iv_main_icon)
    private ImageView mMainIcon;
    @ViewInject(R.id.msm_main)
    private MySlidingMenu mMySlidingMenu;
    @ViewInject(R.id.vp_main)
    private NoScrollViewPager mViewPager;
    @ViewInject(R.id.iv_head_left)
    private ImageView mImgLeftHead;
    @ViewInject(R.id.tv_main_title)
    private TextView mMainTitle;
    @ViewInject(R.id.tv_account_name)
    private TextView mAccountName;
    @ViewInject(R.id.left_lv)
    private ListView mListViewMain;
   */
/* @ViewInject(R.id.iv_main_search)
    private ImageView mSearchImg;*//*

    private ArrayAdapter<String> mAdapter;
    private List<BaseFragment> mFragments=new ArrayList<>();
    private int scrollIndex;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ViewUtils.inject(this);
    //    setOverflowButtonAlways();
     //   initToolbar();
        initHead();
//        getActionBar().setDisplayShowHomeEnabled(false);
        init();
    }

    private void initHead() {
        mMainIcon.setImageResource(R.drawable.head);
        mMainIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mMySlidingMenu.getSlidingmenuStatus() == MySlidingMenu.SlidingmenuStatus.OPEN
                        || mMySlidingMenu.getSlidingmenuStatus() == MySlidingMenu.SlidingmenuStatus.DRAGING) {
                    mMySlidingMenu.closeSlidingMenu();
                } else {
                    mMySlidingMenu.openSlidingMenu();
                }
            }
        });
        */
/*mSearchImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(MainActivity.this,SearchActivity.class);
                startActivity(intent);
            }
        });*//*

    }



    private void init() {
        initFragment();
        initMain();
        initLeftMenu();
    }
    private List<ChangeColorIconWithText> mTabIndicators = new ArrayList<ChangeColorIconWithText>();
    private void initBottomView(){
        ChangeColorIconWithText one = (ChangeColorIconWithText) findViewById(R.id.id_indicator_one);
        mTabIndicators.add(one);
        ChangeColorIconWithText two = (ChangeColorIconWithText) findViewById(R.id.id_indicator_two);
        mTabIndicators.add(two);
        ChangeColorIconWithText three = (ChangeColorIconWithText) findViewById(R.id.id_indicator_three);
        mTabIndicators.add(three);

        one.setOnClickListener(this);
        two.setOnClickListener(this);
        three.setOnClickListener(this);
        one.setIconAlpha(1.0f);

    }
    private void initMain() {
        initBottomView();
        mViewMain.setOnMenuStatusChangeListener(new MainContenLinearLayout.OnMenuStatusChangeListener() {
            @Override
            public boolean isOpen() {
                if (mMySlidingMenu.getSlidingmenuStatus() != MySlidingMenu.SlidingmenuStatus.CLOSE) {
                    return true;
                }
                return false;
            }

            @Override
            public void close() {
                mMySlidingMenu.closeSlidingMenu();
            }
        });
        initViewPager();
    }

    private void initViewPager() {
        mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return mFragments.get(position);
            }

            @Override
            public int getCount() {
                return mFragments == null ? 0 : mFragments.size();
            }
        });
        mViewPager.addOnPageChangeListener(this);
        onPageSelected(0);
    }

    private void initLeftMenu() {
        mImgLeftHead.setImageResource(R.drawable.head);
        mListViewMain.setAdapter(mAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1,
                Cheeses.QQ_FUCTIONS));
        mListViewMain.setOnItemClickListener(this);
        mMySlidingMenu.setOnSlidingMenuStatusChangeListener(new MySlidingMenu.OnSlidingMenuStatusChangeListener() {
            @Override
            public void open() {

            }

            @Override
            public void close() {
                ObjectAnimator ta=ObjectAnimator.ofFloat(mMainIcon,"translationX",5.0f);
                ta.setDuration(500);
                ta.setInterpolator(new CycleInterpolator(5.0f));
                ta.start();
            }

            @Override
            public void drag(float percent) {
                ViewCompat.setAlpha(mMainIcon,1-percent);
            }
        });
        mMySlidingMenu.setOnSlidingMenuScrollListener(new MySlidingMenu.OnSlidingMenuScrollListener() {
            @Override
            public boolean isScroll() {
                if(scrollIndex==0){
                    return true;
                }
                return false;
            }
        });
    }

    private void initFragment() {
        mFragments.add(new OneFragment());
        mFragments.add(new Category());
        mFragments.add(new ThreeFragment());
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    }

    @Override
    public void onClick(View v) {
        clickTab(v);
    }
    private void resetOtherTabs(){
        for (int i = 0; i < mTabIndicators.size(); i++){
            mTabIndicators.get(i).setIconAlpha(0);
        }
    }
    private void clickTab(View v){
        resetOtherTabs();

        switch (v.getId()){
            case R.id.id_indicator_one:
                mTabIndicators.get(0).setIconAlpha(1.0f);
                mViewPager.setCurrentItem(0, false);
                break;
            case R.id.id_indicator_two:
                mTabIndicators.get(1).setIconAlpha(1.0f);
                mViewPager.setCurrentItem(1, false);
                break;
            case R.id.id_indicator_three:
                mTabIndicators.get(2).setIconAlpha(1.0f);
                mViewPager.setCurrentItem(2, false);
                break;
        }
    }
    @Override
    public void onPageScrolled(int position, float positionOffset,
                               int positionOffsetPixels){
        if (positionOffset > 0){
            ChangeColorIconWithText left = mTabIndicators.get(position);
            ChangeColorIconWithText right = mTabIndicators.get(position + 1);
            left.setIconAlpha(1 - positionOffset);
            right.setIconAlpha(positionOffset);
        }
    }

    @Override
    public void onPageSelected(int position){
        this.scrollIndex=position;
        mMainTitle.setText(mTabIndicators.get(position).getText());
    }

    @Override
    public void onPageScrollStateChanged(int state){
        // TODO Auto-generated method stub

    }

}
*/
